package com.chenbei.system.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.chenbei.common.annotation.Desensitize;
import com.chenbei.common.annotation.DomainUrl;
import com.chenbei.common.domain.BaseEntity;
import com.chenbei.common.enums.DesensitizeTypeEnum;
import com.chenbei.system.vo.resp.AdminUserMenuResp;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Schema
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("sys_user")
public class SysUser extends BaseEntity {

    @Schema(description = "主键ID")
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @Schema(description = "用户名")
    @TableField("username")
    @NotBlank(message = "用户名不能为空")
    private String username;

    @Schema(description = "昵称")
    @TableField("nickname")
    @NotBlank(message = "昵称不能为空")
    private String nickname;

    @Schema(description = "密码")
    @TableField("password")
    @NotBlank(message = "密码不能为空")
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;

    @Schema(description = "性别")
    @TableField("sex")
    private Integer sex;

    @Schema(description = "邮箱")
    @TableField("email")
    private String email;

    @Schema(description = "手机号")
    @TableField("phone")
    @Desensitize(type=DesensitizeTypeEnum.PHONE)
    private String phone;

    @Schema(description = "状态")
    @TableField("status")
    private Integer status;

    @Schema(description = "头像")
    @TableField("avatar")
    @DomainUrl
    private String avatar;

    @Schema(description = "所属角色列表")
    @TableField(exist = false)
    private List<Long> roleIds;

    @Schema(description = "所属部门")
    @TableField(exist = false)
    private Long departmentId;

    @Schema(description = "角色列表")
    @TableField(exist = false)
    private List<SysRole> roles;

    @Schema(description = "用户菜单")
    @TableField(exist = false)
    private List<AdminUserMenuResp> menus;

    @Schema(description = "岗位ID")
    @TableField(exist = false)
    private Long postId;

    @Schema(description = "岗位信息")
    @TableField(exist = false)
    private SysPost post;

    @Schema(description = "组织ID")
    @TableField(exist = false)
    private Long orgId;

    @Schema(description = "组织信息")
    @TableField(exist = false)
    private SysOrganization organization;

    @Schema(description = "备注")
    @TableField("remark")
    private String remark;
}
